/**
 * 
 */
package pl.com.like.sequoia.dao.admin;

import org.hibernate.criterion.Expression;

import pl.com.like.sequoia.dao.GenericDao;
import pl.com.like.sequoia.model.admin.Config;
import pl.com.like.sequoia.model.bio.enums.ConfigType;

/**
 * @author Pawel Wolanski
 * 
 */
public class ConfigDao extends GenericDao<Config, Long> implements IConfigDao {

	/**
	 * @param type
	 */
	public ConfigDao() {
		super(Config.class);
	}

	/** {@inheritDoc} */
	public Config get(ConfigType key) {
		Config config = null;
		if (null != key) {
			config = (Config) getCriteria().add(Expression.like("name", key.getKey())).uniqueResult();
		}
		return config;
	}

	/**
	 * {@inheritDoc}
	 */
	public void set(Config conf, ConfigType key) {
		conf.setName(key.getKey());
		saveOrUpdate(conf);
	}

}
